package com.cn.sl.server.api.system.menu.model.dto

import com.cn.sl.server.api.system.menu.model.entity.MenuEntity
import com.cn.sl.server.api.system.menu.model.enumerate.MenuType
import io.swagger.v3.oas.annotations.media.Schema

@Schema(description = "菜单")
data class MenuDto(
    @field:Schema(description = "菜单id")
    val id: Long,
    /**
     * name
     */
    @field:Schema(description = "菜单名称")
    val name: String,

    /**
     * path
     */
    @field:Schema(description = "菜单路径")
    val path: String,


    /**
     * 父级id
     */
    @field:Schema(description = "父级id")
    val parentId: Long?,

    /**
     * 组件
     */
    @field:Schema(description = "组件")
    val component: String?,

    /**
     * 重定向地址
     */
    @field:Schema(description = "重定向地址")
    val redirect: String?,

    /**
     * 菜单类型
     */
    @field:Schema(description = "菜单类型")
    val type: MenuType,

    /**
     * 扩展属性
     */
    @field:Schema(description = "扩展属性")
    val meta: Map<String, Any>,
) {
    constructor(entity: MenuEntity) : this(
        entity.id,
        entity.name,
        entity.path,
        entity.parentId,
        entity.component,
        entity.redirect,
        entity.type,
        entity.meta
    )
}